﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NPSoft.Ferrero.Framework.Utility
{

    /// <summary>
    /// 系统提示信息实体对象。
    /// </summary>
    public class NPMessage
    {
        private List<string> _msgs;

        /// <summary>
        /// 构造函数
        /// </summary>
        public NPMessage()
        {
            this.Success = true;
            this.Type = NPMessageType.Alert;
            this.Data = "";
            _msgs = new List<string>();
        }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success
        {
            get;
            set;
        }

        /// <summary>
        /// 提示类型
        /// </summary>
        public NPMessageType Type
        {
            get;
            set;
        }

        /// <summary>
        /// 提示信息
        /// </summary>
        public string Message
        {
            get
            {
                string sRet = "";
                if (this._msgs.Count > 0)
                {
                    foreach (string s in _msgs)
                    {
                        sRet += s + "\n";
                    }
                    sRet = sRet.Substring(0, sRet.Length - 1);
                }
                return sRet;
            }
            set
            {
                string[] msgs = value.Split('\n');
                foreach (string s in msgs)
                {
                    this._msgs.Add(s);
                }
            }
        }

        /// <summary>
        /// 扩展数据
        /// </summary>
        public string Data
        {
            get;
            set;
        }

        /// <summary>
        /// 添加提示信息
        /// </summary>
        /// <param name="message"></param>
        public void Add(string message)
        {
            _msgs.Add(message);
        }
    }

    /// <summary>
    /// 信息类型
    /// </summary>
    public enum NPMessageType
    {
        /// <summary>
        /// 警告信息
        /// </summary>
        Alert = 0,
        /// <summary>
        /// 提示信息
        /// </summary>
        Infomation = 1,
        /// <summary>
        /// 确认信息
        /// </summary>
        Question = 2,
        /// <summary>
        /// 错误信息
        /// </summary>
        Error = 3
    }
}